home *** CD-ROM | disk | FTP | other *** search
- /*
- File: USBTabletModuleHeader.c
-
- Contains: USBTabletModule Header file
-
- Version: xxx put version here xxx
-
- Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
-
- #include "USBTabletModule.h"
- #include "USBTabletModuleVersion.h"
-
- extern usbWacomPBStruct myWacomPB;
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- 0x056a, // vendor = not device specific
- 0, // product = not device specific
- 0, // version of product = not device specific
- kUSBMouseInterfaceProtocol, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- kUSBHIDInterfaceClass, // Interface Class
- kUSBBootInterfaceSubClass, // Interface SubClass
- kUSBMouseInterfaceProtocol, // Interface Protocol
-
-
- // Driver Info
- "\pUSBHIDWacomModule", // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kWacomHexMajorVers,
- kWacomHexMinorVers,
- kWacomCurrentRelease,
- kWacomReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch+kUSBDoNotMatchInterface+kUSBDoNotMatchGenericDevice // Flags (currently undefined)
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- WacomDriverValidateHW, // Hardware Validation Procedure
- WacomDeviceInitialize, // Initialization Procedure
- WacomInterfaceInitialize, // Interface Initialization Procedure
- WacomDriverFinalize, // Finalization Procedure
- WacomDriverNotifyProc, // Driver Notification Procedure
- };
-
-
- // Hardware Validation
- // Called upon load by Expert
- OSStatus WacomDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- {
- #pragma unused (device)
- #pragma unused (desc)
-
- return (OSStatus)kUSBNoErr;
- }
-
-
- // Initialization function
- // Called upon load by Expert
- OSStatus WacomDeviceInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
-
- //DebugStr("\pIn Wacom Driver");
- // until we get going, it's okay to accept a call to finalize
- DeviceInitialize(device, pDesc, busPowerAvailable);
- return (OSStatus)kUSBNoErr;
- }
-
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- OSStatus WacomInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
- {
- #pragma unused (interfacenum)
- #pragma unused (pInterface)
- #pragma unused (pDesc)
- #pragma unused (device)
-
- return (OSStatus)noErr;
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- OSStatus WacomDriverFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
- OSStatus myErr;
- //USBHIDData theWacomData;
-
- USBExpertStatus(theDeviceRef, "\pUSBHIDWacomModule: Finalize", theDeviceRef);
-
- /*
- if (myWacomPB.pSHIMInterruptRoutine)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDWacomModule: Release Wacom buttons", theDeviceRef);
- theWacomData.Wacom.buttons = 0;
- theWacomData.Wacom.XDelta = 1;
- theWacomData.Wacom.YDelta = 1;
- (*myWacomPB.pSHIMInterruptRoutine)(myWacomPB.interruptRefcon, (void *)&theWacomData);
- }
- */
-
- if (myWacomPB.pCursorDeviceInfo != 0)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDWacomModule: Remove CDM device", theDeviceRef);
- CursorDeviceDisposeDevice(myWacomPB.pCursorDeviceInfo);
- myWacomPB.pCursorDeviceInfo = 0;
- }
-
- if (myWacomPB.pipeRef)
- {
- USBExpertStatus(theDeviceRef, "\pUSBHIDWacomModule: Aborting interrupt pipe", theDeviceRef);
- USBAbortPipeByReference(myWacomPB.pipeRef);
- }
-
- myWacomPB.pb.usbReference = theDeviceRef;
- myWacomPB.pb.pbVersion = kUSBCurrentPBVersion;
- myWacomPB.pb.usbFlags = 0;
- myWacomPB.pb.usbRefcon = 0;
- myWacomPB.pb.usbCompletion = (USBCompletion)-1;
-
- myErr = USBDeallocMem(&myWacomPB.pb);
-
- return (OSStatus)noErr;
- }
-
- OSStatus WacomDriverNotifyProc(UInt32 notification, void *pointer, UInt32 refCon)
- {
- #pragma unused (pointer)
- #pragma unused (notification)
- return(kUSBNoErr);
- }
-
- void DeviceInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDeviceDescriptor, UInt32 busPowerAvailable)
- {
- #pragma unused (pDeviceDescriptor)
- static Boolean beenThereDoneThat = false;
-
- DebugStr("\pIn Wacom Driver");
- if(beenThereDoneThat)
- {
- USBExpertFatalError(device, kUSBInternalErr, "\pWacom driver is not reentrant!", 0);
- return;
- }
- beenThereDoneThat = true;
-
- InitParamBlock(device, &myWacomPB.pb);
-
- myWacomPB.deviceRef = device;
- myWacomPB.pSHIMInterruptRoutine = nil;
- myWacomPB.pSavedInterruptRoutine = nil;
-
- myWacomPB.busPowerAvailable = busPowerAvailable;
- myWacomPB.transDepth = 0;
- myWacomPB.retryCount = kWacomRetryCount;
-
- myWacomPB.deviceRef = device;
- myWacomPB.interfaceRef = nil;
- myWacomPB.pipeRef = nil;
-
- myWacomPB.pb.usbRefcon = kFindInterface;
- myWacomPB.pb.usbReference = device;
- myWacomPB.pb.pbLength = sizeof(usbWacomPBStruct);
- myWacomPB.unitsPerInch = (Fixed)(400<<16);
- myWacomPB.pCursorDeviceInfo = 0;
- API_ControlDevice(kHIDEnableDemoMode,0);
-
- InitParamBlock(device, &myWacomPB.pb);
- InitiateTransactionProc(&myWacomPB.pb);
- }
-
-